package com.cc.eb.model;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.Version;
import lombok.Getter;
import lombok.Setter;

import java.io.Serializable;
import java.math.BigDecimal;

@Getter
@Setter
//@ToString
public class EbProduct implements Serializable {

    @TableId
    private Integer epId;
    private String epName;
    private String epDescription;
    private BigDecimal epPrice;
    private Integer epStock;
    private Integer epcId;//商品的一级分类id
    private Integer epcChildId;//商品的二级分类的id
    private String epFileName;

    @Version
    private Integer version;//版本号
    @TableField(exist = false)//表名这个属性与eb_product表的字段没有对应
    private int count = 1;//表示购买数量

    @TableField(exist = false)//表名这个属性与eb_product表的字段没有对应
    private BigDecimal amount = new BigDecimal("0.00");//表示商品总价

    @Override
    public int hashCode() {
        return 100;
    }

    @Override
    public boolean equals(Object obj) {
        if(obj==null){
            return false;
        }
        if(obj==this){
            return  true;
        }
        if(obj instanceof EbProduct){
            EbProduct ebProduct = (EbProduct) obj;
            if(this.epId.equals(ebProduct.getEpId())){//主键对应属性
                return true;
            }else{
                return false;
            }
        }
        return false;
    }

    @Override
    public String toString() {
        return "EbProduct{" +
                "epId=" + epId +
                ", epName='" + epName + '\'' +
                ", epDescription='" + epDescription + '\'' +
                ", epPrice=" + epPrice +
                ", epStock=" + epStock +
                ", epcId=" + epcId +
                ", epcChildId=" + epcChildId +
                ", epFileName='" + epFileName + '\'' +
                '}'+"\n";
    }
}